//
//  JHMiddleTutorListController.m
//  JuniRengLish_iOS
//
//  Created by revogi on 2019/5/9.
//  Copyright © 2019 revogi. All rights reserved.
//

#import "JHMiddleTutorListController.h"
#import "JHMiddleTutorTableViewCell.h"
#import "JHMiddenBookModel.h"
#import "JHMiddleListDetailViewController.h"
#import "JHMiddleListTopDetailController.h"

//标志符
static NSString * const cellID = @"JHMiddleTutorTableViewCell";
@interface JHMiddleTutorListController () <UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView *tableView;

@end

@implementation JHMiddleTutorListController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationItem.title=self.navTitle;
    self.tableView.rowHeight=55;
}

-(void)initUI
{
    
    self.tableView=[[UITableView alloc]initWithFrame:CGRectMake(0,0,JKScreenW,JKScreenH) style:UITableViewStyleGrouped];
    self.tableView.delegate=self;
    self.tableView.dataSource=self;
    [self.tableView registerNib:[UINib nibWithNibName:@"JHMiddleTutorTableViewCell" bundle:nil] forCellReuseIdentifier:cellID];
    self.tableView.scrollEnabled=NO;
    [self.view addSubview:self.tableView];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.001;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    
    return 0.001;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    return nil;
    
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    return nil;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    JHMiddleTutorTableViewCell *cell= [tableView dequeueReusableCellWithIdentifier:cellID forIndexPath:indexPath];
    JHMiddenBookModel *model=self.dataArray[indexPath.row];
    cell.titleLable.text=model.unitname;;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    JHMiddenBookModel *model=self.dataArray[indexPath.row];
    if ([model.data.titlename containsString:@"_"]) {
        JHMiddleListTopDetailController *vc=[[JHMiddleListTopDetailController alloc]init];
        vc.model=model;
        [self.navigationController pushViewController:vc animated:YES];
    }else{
        JHMiddleListDetailViewController *vc=[[JHMiddleListDetailViewController alloc]init];
        vc.model=model;
        [self.navigationController pushViewController:vc animated:YES];
    }
    
}


/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
